package jalgebrava.group.morphisms;

import static jalgebrava.group.util.GroupMixins.*;
import static jalgebrava.util.collections.IterableMixins.*;
import jalgebrava.group.Group;
import jalgebrava.group.GroupElement;
import jalgebrava.util.Pair;

import org.apache.log4j.Logger;

public final class IsomorphicTester {
	private static final Logger logger =Logger.getLogger(IsomorphicTester.class);
	
	private IsomorphicTester() {
		// hidden
	}
	
	public static final <G,H> boolean areIsomorphic(Group<G> g, Group<H> h) {
		if (g.size() != h.size()) {
			return false;
		}
		for (Pair<GroupElement<G>,GroupElement<H>> p : zip(elementsInDescendingOrder(g), elementsInDescendingOrder(h))) {
			if (p.a.order() != p.b.order()) {
				return false;
			}
		}
		logger.warn("Maybe too quickly concluding isomorphism based on orders only...");
		return true;
	}
}
